package business;

import data.IMedicamentDAO;
import data.implementation.MedicamentDBAccess;
import exception.*;
import java.util.ArrayList;
import java.util.List;
import model.*;

/**
 *
 * @author BACQ Justine et SACRE Sauvane
 */

public class MedicamentManager {
    private IMedicamentDAO medicDao= new MedicamentDBAccess();
    private SoinJournalierManager soinJManager;
    
    public MedicamentManager(){
        soinJManager = new SoinJournalierManager();
    }
    
    public List<Medicament> getMedicamentpourSoinSession(Session sessionEnCours) throws ExceptionConnection, ExceptionAnimalSoin, ExceptionSessionAnimalFini, ExceptionSoinJournalier, ExceptionPrescription, MedException {
        List<SoinJournalier> soinJSession = soinJManager.getAllSoinJForSession(sessionEnCours);
        List<Medicament> listMedic = new ArrayList<Medicament>();
        for(SoinJournalier soinJ : soinJSession){
            List<Medicament> tempMedic  = medicDao.getMedicamentPrescritSession(soinJ);
            for (Medicament medoc: tempMedic)
            {
            listMedic.add(medoc);
            }
        }
        return  listMedic;
    }
}
